home *** CD-ROM | disk | FTP | other *** search
/ Delphi 5 for Professionals / DELPHI5.iso / AddOns / Components / Swiftsoft Multimedia Tools / MMTOOL3.EXE / MMCDATyp.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1998-07-19  |  8.3 KB  |  243 lines

  1. {========================================================================}
  2. {=                (c) 1995-98 SwiftSoft Ronald Dittrich                 =}
  3. {========================================================================}
  4. {=                          All Rights Reserved                         =}
  5. {========================================================================}
  6. {=  D 01099 Dresden             = Tel.: +0351-8012255                   =}
  7. {=  Loewenstr.7a                = info@swiftsoft.de                     =}
  8. {========================================================================}
  9. {=  Actual versions on http://www.swiftsoft.de/mmtools.html             =}
  10. {========================================================================}
  11. {=  This code is for reference purposes only and may not be copied or   =}
  12. {=  distributed in any format electronic or otherwise except one copy   =}
  13. {=  for backup purposes.                                                =}
  14. {=                                                                      =}
  15. {=  No Delphi Component Kit or Component individually or in a collection=}
  16. {=  subclassed or otherwise from the code in this unit, or associated   =}
  17. {=  .pas, .dfm, .dcu, .asm or .obj files may be sold or distributed     =}
  18. {=  without express permission from SwiftSoft.                          =}
  19. {=                                                                      =}
  20. {=  For more licence informations please refer to the associated        =}
  21. {=  HelpFile.                                                           =}
  22. {========================================================================}
  23. {=  $Date: 19.02.98 - 23:38:39 $                                        =}
  24. {========================================================================}
  25. unit MMCDATyp;
  26.  
  27. {$I COMPILER.INC}
  28.  
  29. interface
  30.  
  31. uses
  32.     Windows,
  33.     MMSystem,
  34.     MMSCSI;
  35.  
  36. const
  37.     SECTOR_LEN   = 2368;
  38.     FRAME_SIZE   = 2352;
  39.     DATA_SECTOR  = 2048;
  40.     TIMEOUT      = 10000;
  41.     FRAME_OFFSET = 150;
  42.     SINGLE_SPEED = 75*FRAME_SIZE;
  43.  
  44. type
  45.     THCDDA = integer;
  46.     
  47.     PASPIDeviceInfo = ^TASPIDeviceInfo;
  48.     TASPIDeviceInfo = packed record
  49.        Adapter   : integer;        // haId
  50.        TargetId  : integer;
  51.        LUN       : Integer;
  52.        Data      : TScsiInquiry;
  53.        lpNext    : PASPIDeviceInfo;
  54.     end;
  55.  
  56.     {==========================================================================}
  57.     PASPIInfo = ^TASPIInfo;
  58.     TASPIInfo = packed record
  59.        FNumAdapters: Byte;
  60.        FDevices    : PASPIDeviceInfo;
  61.     end;
  62.  
  63.     {==========================================================================}
  64.     TCDTrackType = (ttData,ttAudio);
  65.  
  66.     {==========================================================================}
  67.     PCDTrackInfo = ^TCDTrackInfo;
  68.     TCDTrackInfo = packed record
  69.        Number        : Integer;
  70.        Start         : Integer;   // MSF
  71.        Length        : Integer;   // MSF
  72.        TrackType     : TCDTrackType;
  73.        CopyProtected : LongBool;
  74.        PreEmphasis   : LongBool;
  75.     end;
  76.  
  77.     {==========================================================================}
  78.     PCDTrackList = ^TCDTrackList;
  79.     TCDTrackList = packed record
  80.        nTracks: Integer;
  81.        Tracks : array[0..99] of TCDTrackInfo;
  82.     end;
  83.  
  84. const
  85.     AUTO     = 'AutoDetect';
  86.     ATAPI    = 'ATAPI';
  87.     CYBER    = 'CYBER';
  88.     DEC_     = 'DEC';
  89.     GRUNDIG  = 'GRUNDIG';
  90.     HITACHI  = 'HITACHI';
  91.     HP       = 'HP';
  92.     IBM      = 'IBM';
  93.     IMS      = 'IMS';
  94.     KODAK    = 'KODAK';
  95.     MATSHITA = 'MATSHITA';
  96.     MITSUMI  = 'MITSUMI';
  97.     MP       = 'MP';
  98.     MS       = 'MS';
  99.     NEC      = 'NEC';
  100.     PHILIPS  = 'PHILIPS';
  101.     PIONEER  = 'PIONEER';
  102.     PLASMON  = 'PLASMON';
  103.     PLEXTOR  = 'PLEXTOR';
  104.     RICOH    = 'RICOH';
  105.     SONY     = 'SONY';
  106.     TOSHIBA  = 'TOSHIBA';
  107.     TEAC     = 'TEAC';
  108.     YAMAHA   = 'YAMAHA';
  109.  
  110. type
  111.     {==========================================================================}
  112.     TCDDeviceType = (dtAUTO,
  113.                      dtATAPI,
  114.                      dtCYBER,
  115.                      dtDEC,
  116.                      dtGRUNDIG,
  117.                      dtHITACHI,
  118.                      dtHP,
  119.                      dtIBM,
  120.                      dtIMS,
  121.                      dtKODAK,
  122.                      dtMATSHITA,
  123.                      dtMITSUMI,
  124.                      dtMP,
  125.                      dtMS,
  126.                      dtNEC,
  127.                      dtPHILIPS,
  128.                      dtPIONEER,
  129.                      dtPLASMON,
  130.                      dtPLEXTOR,
  131.                      dtRICOH,
  132.                      dtSONY,
  133.                      dtTOSHIBA,
  134.                      dtTEAC,
  135.                      dtYAMAHA);
  136. const
  137.     {==========================================================================}
  138.     CDDeviceTypes: array[0..23] of string =
  139.                     (AUTO,
  140.                      ATAPI,
  141.                      CYBER,
  142.                      DEC_,
  143.                      GRUNDIG,
  144.                      HITACHI,
  145.                      HP,
  146.                      IBM,
  147.                      IMS,
  148.                      KODAK,
  149.                      MATSHITA,
  150.                      MITSUMI,
  151.                      MP,
  152.                      MS,
  153.                      NEC,
  154.                      PHILIPS,
  155.                      PIONEER,
  156.                      PLASMON,
  157.                      PLEXTOR,
  158.                      RICOH,
  159.                      SONY,
  160.                      TOSHIBA,
  161.                      TEAC,
  162.                      YAMAHA);
  163.  
  164.  
  165. const
  166.     {==========================================================================}
  167.     { ASPI Error codes                                                         }
  168.     {==========================================================================}
  169.     ASPI_ERRBASE       = -100;
  170.     ASPI_NOERROR       = 0;
  171.     ASPI_DLLERROR      = ASPI_ERRBASE - 1;
  172.     ASPI_NOMANAGER     = ASPI_ERRBASE - 2;
  173.     ASPI_NOADAPTER     = ASPI_ERRBASE - 3;
  174.     ASPI_INVALIDDEVICE = ASPI_ERRBASE - 4;
  175.     ASPI_TIMEOUT       = ASPI_ERRBASE - 5;
  176.     ASPI_UNKNOWNERROR  = ASPI_ERRBASE - 6;
  177.  
  178.     {==========================================================================}
  179.     { CDDA Error codes                                                         }
  180.     {==========================================================================}
  181.     CDDA_ERRBASE       = 0;
  182.     CDDA_NOERROR       = CDDA_ERRBASE;
  183.     CDDA_INITFAILURE   = CDDA_ERRBASE - 1;
  184.     CDDA_INVALHANDLE   = CDDA_ERRBASE - 2;
  185.     CDDA_INVALPARAM    = CDDA_ERRBASE - 3;
  186.     CDDA_INVALIDDEVICE = CDDA_ERRBASE - 4;
  187.     CDDA_ALLOCATED     = CDDA_ERRBASE - 5;
  188.     CDDA_NOTREADY      = CDDA_ERRBASE - 6;
  189.     CDDA_CANNOTOPEN    = CDDA_ERRBASE - 7;
  190.     CDDA_CANNOTCLOSE   = CDDA_ERRBASE - 8;
  191.     CDDA_CANNOTLOAD    = CDDA_ERRBASE - 9;
  192.     CDDA_CANNOTPLAY    = CDDA_ERRBASE - 10;
  193.     CDDA_CANNOTPAUSE   = CDDA_ERRBASE - 11;
  194.     CDDA_CANNOTRESUME  = CDDA_ERRBASE - 12;
  195.     CDDA_CANNOTSTOP    = CDDA_ERRBASE - 13;
  196.     CDDA_CANNOTLOCK    = CDDA_ERRBASE - 14;
  197.     CDDA_CANNOTREAD    = CDDA_ERRBASE - 15;
  198.     CDDA_SYNCERROR     = CDDA_ERRBASE - 16;
  199.     CDDA_UNKNOWNERROR  = CDDA_ERRBASE - 17;
  200.  
  201. function MSFToFrame(MSF: Longint): Longint;
  202. function Frame2MSF(Frame: Longint; M, S, F: PInteger): Longint;
  203. function FrameToMSF(Frame: Longint): Longint;
  204.  
  205. implementation
  206.  
  207. {==============================================================================}
  208. function MSFToFrame(MSF: Longint): Longint;
  209. begin
  210.    Result := MCI_MSF_FRAME(MSF);
  211.    Result := Result + 75 * MCI_MSF_SECOND(MSF);
  212.    Result := Result + 75 * 60 * MCI_MSF_MINUTE(MSF);
  213. end;
  214.  
  215. {==============================================================================}
  216. function Frame2MSF(Frame: Longint; M, S, F: PInteger): Longint;
  217. var
  218.   Temp : Integer;
  219. begin
  220.   Temp:= (Frame mod 75);
  221.   if (F <> nil) then F^:= Temp;
  222.   Result:= Temp shl 16;
  223.  
  224.   Temp:= Frame div 75;
  225.   Result:= Result or (Temp div 60);
  226.   Temp:= Temp mod 60;
  227.   if (M <> nil) then M^:= Result and $FF;
  228.  
  229.   if (S <> nil) then S^:= Temp;
  230.   Result:= Result or (Temp shl 8);
  231. end;
  232.  
  233. {==============================================================================}
  234. function FrameToMSF(Frame: Longint): Longint;
  235. var
  236.    M,S,F: integer;
  237. begin
  238.    Frame2MSF(Frame, @M, @S, @F);
  239.    Result := MCI_MAKE_MSF(M, S, F);
  240. end;
  241.  
  242. end.
  243.